package com.yupi.kqapibackend.controller;

import com.yupi.kqapibackend.annotation.AuthCheck;
import com.yupi.kqapibackend.common.BaseResponse;
import com.yupi.kqapibackend.common.ResultUtils;
import com.yupi.kqapibackend.mapper.UserInterfaceInfoMapper;
import com.yupi.kqapibackend.model.vo.InterfaceInfoVO;
import com.yupi.kqapibackend.service.UserInterfaceInfoService;
import lombok.extern.slf4j.Slf4j;
import org.apache.xmlbeans.impl.xb.xmlconfig.Extensionconfig;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 接口分析类
 */
@RestController
@Slf4j
@RequestMapping("/analysis")
public class AnalysisController {

    @Resource
    UserInterfaceInfoService userInterfaceInfoService;

    /**
     * 管理员的接口分析列表
     * @return 返回调用次数前三名的接口的信息
     */
    @AuthCheck
    @GetMapping("top/interface/invoke")
    public BaseResponse<List<InterfaceInfoVO>> getTopThreeInterfaceInfo() {
        List<InterfaceInfoVO> topThreeInterface = userInterfaceInfoService.getTopThreeInterface();
        return ResultUtils.success(topThreeInterface);
    }
}
